package com.aaa.member.controller.api;

import com.aaa.entity.Member;
import com.aaa.entity.MemberLevel;
import com.aaa.member.service.MemberLevelService;
import com.aaa.security.annotation.HasPermission;
import com.aaa.security.annotation.MyLog;
import com.aaa.vo.MemberLevelVo;
import com.aaa.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author JYH
 * @version 1.0
 * @date 2023/3/1 16:43
 */
@Api(value = "/member/api/memberLevel", tags = {"会员等级"})
@RestController
@RequestMapping("/member/api/memberLevel")
public class MemberLevelController {

    @Autowired
    private MemberLevelService memberLevelService;

    /**
     *分页查询会员等级
     * @author JYH
     * @date 2023/3/1 19:11
     * @description
     currentPage
     * @param pageSize
     * @param name
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "string", name = "name", value = "", required = true)
    })
    @ApiOperation(value = "分页查询会员等级    currentPage", notes = "分页查询会员等级    currentPage", httpMethod = "POST")
    @MyLog(title = "查询会员等级")
    @PostMapping("/findMemberLevel")
    @HasPermission(value = "memberLevel:search")
    public Result findMemberLevel(Integer currentPage, Integer pageSize,  String name){
        return memberLevelService.findMemberLevel(currentPage,pageSize,name);
    }

    /**
     *查询所有会员等级
     * @author JYH
     * @date 2023/3/1 19:15
     * @description

     */

    @ApiOperation(value = "查询所有会员等级", notes = "查询所有会员等级", httpMethod = "GET")
    @GetMapping("/queryByParam")
    public Result queryByParam(){
        return memberLevelService.queryByParam();
    }

    /**
     *添加会员等级
     * @author JYH
     * @date 2023/3/1 19:26
     * @description
     memberLevel
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "MemberLevel", name = "memberLevel", value = "", required = true)
    })
    @ApiOperation(value = "添加会员等级    memberLevel", notes = "添加会员等级    memberLevel", httpMethod = "POST")
    @MyLog(title = "添加会员等级")
    @PostMapping("/add")
    public Result add(@RequestBody MemberLevel memberLevel){
        Result add = memberLevelService.add(memberLevel);
        return new Result(2000,"成功",add);
    }
    /**
     *修改会员等级
     * @author JYH
     * @date 2023/3/1 19:30
     * @description
     * memberLevel
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "MemberLevel", name = "memberLevel", value = "", required = true)
    })
    @ApiOperation(value = "修改会员等级 memberLevel", notes = "修改会员等级 memberLevel", httpMethod = "POST")
    @MyLog(title = "修改会员等级")
    @PostMapping("/update")
    public Result update(@RequestBody MemberLevel memberLevel){
        boolean b = memberLevelService.updateById(memberLevel);
        return new Result(2000,"成功",b);
    }

    /**
     *删除会员等级
     * @author JYH
     * @date 2023/3/1 19:37
     * @description
     * id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "id", value = "", required = true)
    })
    @ApiOperation(value = "删除会员等级 id", notes = "删除会员等级 id", httpMethod = "DELETE")
    @MyLog(title = "删除会员等级")
    @DeleteMapping("/deleteById")
    public Result delete(Integer id){
        return new Result(2000,"成功", memberLevelService.removeById(id));
    }
}
